﻿<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
		<meta name="apple-mobile-web-app-title" content="思路广惠">
		<title>商品列表</title>
		<meta content="telephone=no" name="format-detection" />
		<link rel="stylesheet" type="text/css" href="../../src/css/layui.css" />
		<link rel="stylesheet" type="text/css" href="../../src/css/base.css?1.0" />
	</head>

	<body class="body-bg">
		
		<header class="flexs-al bg-fff setup-btm padi5m"> 
			<a href="javascript: history.go(-1)" class="padlr5m">
				<i class="iconfont icon-fanhui i2m "></i> 
			</a>
			
			<form class="body-bg padi5m flex1" action="#">
				<i class="iconfont icon-sousuo padlr5m"></i>
				<input type="search" class="bg-no s12m" id="setData" placeholder="搜索" />
			</form>
			<i class="iconfont icon-fanhui i2m padlr5m opa"></i>
		</header>
		
		<section> 
			<ul id="searchshop">
				
			</ul>

		</section>
		 
			<!--商品搜索结果为空-->
			<div class="centre nulls" style="display: none;margin-top: 30%;" > 
				 <img src="../../src/images/null-shangpinjieguochatu.png" /> 
				<p class="top1rem s12m">没有相关的搜索结果</p>
				 
			</div>

	 

		<script type="text/html" id="searchshops">
			{{# for(var i = 0; i < d.PageData.length; i++){ }} 
				<li class=" bg-fff w100" >
					<a href="../order/details.html?typeID={{d.PageData[i].Product_ID}}" class="flexs">
						<figure class="line-ht padi5m" >
							<img class="vw25"  lay-src={{d.img}}{{d.PageData[i].Image_Url}} />
						</figure>
						<div class="flex1 flexs-cs padi5m" >
							<p class="col3 s11m">{{d.PageData[i].Product_Name}}</p>
							<p class="flexs-bw">
								{{# if(d.PageData[i].Product_MallType == "Given"){ }}
								 	<span class="bg-fb7">返还商城</span>
								{{# }else if(d.PageData[i].Product_MallType == "Point"){ }}
									<span class="bg-f62">积分商城</span>
								{{# }else if(d.PageData[i].Product_MallType == "OffLine"){ }}	
									<span class="off-span">线下商城</span>
								{{# } }}
								<span >{{d.PageData[i].Product_VisitTotal}}人浏览</span>
							</p>
							
							<p>
								<strong class="huef36">
									{{# if(d.PageData[i].Product_MallType == "Point"){ }}
										<span class="recom-span">积分</span>{{d.PageData[i].Product_PricePoints}} + 
									{{# } }}
									￥{{d.PageData[i].Product_PriceCash}}
								</strong>
								
							</p>
							{{# if(d.PageData[i].Product_MallType == "Given"){ }}
								<p class="huef36">返还积分：{{d.PageData[i].Product_GivenPoints}}</p>
							{{# } }}
						</div>
					</a>
				</li>
			{{# } }}
		</script>
		<script type="text/html" id="searchbuss">
			<li class="  flex-wr" >
				{{# for(var i = 0; i < d.PageData.length; i++){ }} 
					<a href="../home/homestore.html?{{d.PageData[i].Business_ID}}" class=" w50">
						<figure class="line-ht padi5m" >
							<img class="w100"  src= {{d.PageData[i].Image_Url}} >
						</figure>
						 
							<p class="pad-lr s11m col3 aline">{{d.PageData[i].Business_Name}}</p>
							<p class="flexs-bw pad1rem">
								<span> </span>
								<span >浏览量：{{d.PageData[i].Business_VisitTotal}}</span>
							</p> 
						 
					</a>
				{{# } }}
			</li>
		</script>
		<script src="http://apps.bdimg.com/libs/laytpl.js/1.1/laytpl.js"></script>
		<script src="//cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
		<script src="../../src/js/layui.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../src/js/all.js" type="text/javascript" charset="utf-8"></script>
		<script>
			function getDatas(like) { // 商品请求
				var datas = {
					MallType: silks.getByVal("Belong") ? silks.getByVal("Belong") : "",
					LikeVarchar: silks.getByVal("LikeVarchar") ? silks.getByVal("LikeVarchar") : "",
					TypeID: silks.getByVal("TypeID") ?silks.getByVal("TypeID") :""
				};
				if(like) {
					datas.LikeVarchar = like;
					datas.TypeID = "";
					$("#searchshop").html("");
				}
				 
				silks.flows(["#searchshops", "#searchshop"], "/WorkProduct/GetProductList", datas, function() {
					if(this.Return_Data.PageData.length == 0) {
						$("section").hide();
						$(".nulls").show();
					} else {
						$("section").show();
						$(".nulls").hide();
					}
				});

				document.getElementById("setData").value = datas.LikeVarchar;
			}
			function getBuss(like) { // 店铺请求
				var datas = {
						LikeVar: silks.getByVal("LikeVarchar") ? silks.getByVal("LikeVarchar") : "",
						Longitude: "",
						Latitude: "",
						Distance: 0,
						Place: "",
				  		OrderType: ""
				};
				if(like) {
					datas.LikeVar = like;
					$("#searchshop").html("");
				}
				silks.flows(["#searchbuss", "#searchshop"], "/WorkProduct/GetBusinessList", datas, function() {
					 
					if(this.Return_Data.PageData.length == 0) {
						$("section").hide();
						$(".nulls").show();
					} else {
						$("section").show();
						$(".nulls").hide();
					}
					var errowimg = document.images;
					for(var i = 0; i < errowimg.length; i++) {
						errowimg[i].onerror = function() {
							this.src = "../../src/images/tp.png";
						}
					}
				});

				document.getElementById("setData").value = datas.LikeVar;
				

			}
			
			// 店铺或者商品搜素
			silks.getByVal("part")==="1"?getBuss():getDatas();
			
			// 关键字搜索
			$(document).on('keypress', function(e) {
				var keycode = e.keyCode;
				var searchName = $("#setData").val();
				if(keycode == '13') {
					e.preventDefault();
					silks.getByVal("part")==="1"?getBuss(searchName):getDatas(searchName); // 店铺或者商品
					 
				}
			});
			
			// 监听滚动条位置，搜索置顶
			var ident = true;
			window.onscroll = function () {
				var len =  document.body.scrollTop;
				if(ident&&len>50){
				 	$("header").addClass("fixed");
				 	ident = false;
				}
				if(!ident&&len<50){
					$("header").removeClass("fixed");
					ident = true;
				}
			};
			
		</script>
		<!--<script type="text/javascript">
			var st = 0;
		 	var tt = 0;
			document.addEventListener("touchmove",function () { 
			 	var a = document.body.scrollTop;
			  		tt++;
			 	if((a-st) < st){
			 		$(".mmm").show();
			 	}
			})
			document.addEventListener("touchend",function () {
			 	$(".mmm").hide();
			})
		</script>-->
	</body>

</html>